<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="../static/assets/css/layui.css">
    <link rel="stylesheet" href="../static/assets/css/view.css"/>
    <title></title>
    <script type="text/javascript">
	function check(form) {
		if (form.title.value == '') {
			alert("标题不能为空");
			form.title.focus();
			return false;
		}
		if (form.type.value == '') {
			alert("分类不能为空");
			form.type.focus();
			return false;
		}
		if (form.content.value == '') {
			alert("内容不能为空");
			form.content.focus();
			return false;
		}
		return true;
	}
</script>
</head>
<body class="layui-view-body">
    <div class="layui-content">
        <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-header">News</div>
                <form class="layui-form layui-card-body" action="/addPost">
                  <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                      <input type="text" name="title"  placeholder="请输入标题" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">作者：</label>
                    <div class="layui-input-inline">
                      <input type="text" name="username" required lay-verify="required"   class="layui-input" value="${username}"  readonly="readonly">
                    </div>
                  </div>
                   <div class="layui-form-item">
                  </div>
                 <input type="hidden" name="userId" value="${userId }"/>
                  <div class="layui-form-item">
                    <label class="layui-form-label">分类：</label>
                    <div class="layui-input-block">
                      <select name="type">
                        <option value=""></option>
                        <c:forEach items="${postList}" var="u">
                        	  <option value="${u.type}">${u.type}</option>
                        </c:forEach>
                      </select>
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <input type="checkbox" name="" title="写作" lay-skin="primary" checked>
                  </div>
                  <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">文本域</label>
                    <div class="layui-input-block">
                      <textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                    
                      <br>
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <div class="layui-input-block">
                      <button class="layui-btn layui-btn-blue" lay-submit lay-filter="formDemo" onclick="return check(this.form)">立即提交</button>
                      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                  </div>
                </form>  
            </div>
        </div>
    </div>
    <script src="../static/assets/layui.all.js"></script>
    <script>
      var form = layui.form
        ,layer = layui.layer;
    </script>
</body>
</html>